package com.itheima.service.serviceImpl;

import com.itheima.domain.pojo.Dept;
import com.itheima.mapper.DeptMapper;
import com.itheima.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author 上官徵羽
 * @version 1.0
 * @since 2025-08-15 15:00
 */
@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptMapper deptMapper;
    @Override
    public List<Dept> getDeptList() {
        return deptMapper.getDeptList();
    }

    @Override
    public void deleteDept(Integer id) {
        deptMapper.deleteDept(id);
    }

    @Override
    public void addDept(Dept dept) {
        LocalDateTime now = LocalDateTime.now();
        dept.setCreateTime(now);
        dept.setUpdateTime(now);
        deptMapper.addDept(dept);
    }

    @Override
    public Dept getDeptId(Integer id) {
        return deptMapper.getDeptId(id);
    }

    @Override
    public void updateDept(Dept dept) {
        LocalDateTime now = LocalDateTime.now();
        dept.setUpdateTime(now);
        deptMapper.updateDept(dept);
    }
}
